import request from './axios'

export const wallApi = {
  // 获取帖子列表
  getPosts(params = {}) {
    return request({
      url: '/wall/posts/',
      method: 'get',
      params
    })
  },

  // 创建帖子
  createPost(data) {
    return request({
      url: '/wall/posts/',
      method: 'post',
      data,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 获取统计数据
  getStats(userId) {
    return request({
      url: '/wall/stats/',
      method: 'get',
      params: { user_id: userId }
    })
  },

  // 获取评论
  getComments(postId) {
    return request({
      url: `/wall/posts/${postId}/comments/`,
      method: 'get'
    })
  },

  // 添加评论
  addComment(data) {
    return request({
      url: '/wall/comments/',
      method: 'post',
      data
    })
  },

  // 点赞/取消点赞
  likePost(postId) {
    return request({
      url: `/wall/posts/${postId}/like/`,
      method: 'post',
      data: {
        user: parseInt(localStorage.getItem('userId'))
      }
    })
  }
} 